package com.ruoyi.web.controller.app;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TLeachRecords;
import com.ruoyi.system.service.ITLeachRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 过滤记录Controller
 * 
 * @author ruoyi
 * @date 2024-05-31
 */
@RestController
@RequestMapping("/system/leachRecords")
public class TLeachRecordsController extends BaseController
{
    @Autowired
    private ITLeachRecordsService tLeachRecordsService;

    /**
     * 查询过滤记录列表
     */
//    @PreAuthorize("@ss.hasPermi('system:leachRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(TLeachRecords tLeachRecords)
    {
        startPage();
        List<TLeachRecords> list = tLeachRecordsService.selectTLeachRecordsList(tLeachRecords);
        return getDataTable(list);
    }

    /**
     * 导出过滤记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:leachRecords:export')")
    @Log(title = "过滤记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TLeachRecords tLeachRecords)
    {
        List<TLeachRecords> list = tLeachRecordsService.selectTLeachRecordsList(tLeachRecords);
        ExcelUtil<TLeachRecords> util = new ExcelUtil<TLeachRecords>(TLeachRecords.class);
        util.exportExcel(response, list, "过滤记录数据");
    }

    /**
     * 获取过滤记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:leachRecords:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tLeachRecordsService.selectTLeachRecordsById(id));
    }

    /**
     * 新增过滤记录
     */
    @PreAuthorize("@ss.hasPermi('system:leachRecords:add')")
    @Log(title = "过滤记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLeachRecords tLeachRecords)
    {
        return toAjax(tLeachRecordsService.insertTLeachRecords(tLeachRecords));
    }

    /**
     * 修改过滤记录
     */
    @PreAuthorize("@ss.hasPermi('system:leachRecords:edit')")
    @Log(title = "过滤记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLeachRecords tLeachRecords)
    {
        return toAjax(tLeachRecordsService.updateTLeachRecords(tLeachRecords));
    }

    /**
     * 删除过滤记录
     */
    @PreAuthorize("@ss.hasPermi('system:leachRecords:remove')")
    @Log(title = "过滤记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tLeachRecordsService.deleteTLeachRecordsByIds(ids));
    }
}
